// components/star/open-star-guide/index.js
import componentBehavior from '../../../behaviors/component';
import { COMPONENT_OPTIONS } from '../../../constants/common';
import { getUserInfo } from '../../../biztools/wex';

Component({
    behaviors: [componentBehavior],
    options: {
        ...COMPONENT_OPTIONS,
    },
    properties: {
        preStoreCount: {
            type: Number,
            value: 0,
        },
    },
    data: {
        type: '',
        bindMobileGuidePopup: {
            show: false,
        },
    },
    methods: {
        handleOpen(e) {
            let { type } = e.currentTarget.dataset;
            if (!type) type = this.data.type;
            if (type) this.setData({ type });
            const userInfo = getUserInfo();
            if (!userInfo || !userInfo.mobile) {
                this.setData({
                    'bindMobileGuidePopup.show': true,
                });
            } else {
                this.triggerEvent('open', type);
            }
        },
    }
})
